<?php

include_once 'Answer_Patterns.php';
include_once 'Mount_DOM_tree.php';

   class Refactoring_Add_Alt_Figure extends Answer_Patterns {

   public function start($domDocument) {
      $result = "";
      $mount_tree = new Mount_DOM_tree();

      $search = $domDocument->getElementsByTagName('img');

      foreach ($search as $f) {
         if (empty($f->getAttribute('alt'))) {
            $answer = ' alt="descricao img"';
            $result .= parent::elementAnswerPatterns("&LT;$f->nodeName&GT;", $f->getLineNo(), $answer, "Adicione o atributo ", "sem o atributo <em>alt</em>");
            $result .= parent::tableAnswer($mount_tree->structHTML($f, 1, 0), $mount_tree->structHTMLElementRefactory($f, 1, 0, "$f->nodeName", 1, $answer));
         }
      }
      if (!empty($result)) {
         $result = parent::titleAnswerPatterns("Adicionar atributo <em>alt</em> para figuras") . $result;
      }
      return $result;
   }
}

?>